home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SCROLLBA.PAK / SCROLLBX.CPP < prev   
C/C++ Source or Header  |  1997-05-06  |  2KB  |  91 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1995 by Borland International, All Rights Reserved
  4. //----------------------------------------------------------------------------
  5. #include <owl/pch.h>
  6. #include <owl/applicat.h>
  7. #include <owl/framewin.h>
  8. #include <owl/scrollba.h>
  9. #include <owl/static.h>
  10. #include <stdio.h>
  11.  
  12. const WORD ID_THERMOMETER = 201;
  13. const WORD ID_STATIC = 202;
  14.  
  15. //
  16. // class TTestWindow
  17. // ~~~~~ ~~~~~~~~~~~
  18. class TTestWindow : public TWindow {
  19.   public:
  20.     TTestWindow();
  21.  
  22.   protected:
  23.     void SetupWindow();
  24.     void EvThermometer(uint code);
  25.  
  26.     TScrollBar* Thermometer;
  27.     TStatic*    Static;
  28.  
  29.   DECLARE_RESPONSE_TABLE(TTestWindow);
  30. };
  31.  
  32. DEFINE_RESPONSE_TABLE1(TTestWindow, TWindow)
  33.   EV_CHILD_NOTIFY_ALL_CODES(ID_THERMOMETER, EvThermometer),
  34. END_RESPONSE_TABLE;
  35.  
  36. //
  37. //
  38. //
  39. TTestWindow::TTestWindow()
  40. :
  41.   TWindow(0, 0, 0)
  42. {
  43.   Attr.X = 20;
  44.   Attr.Y = 20;
  45.   Attr.W = 380;
  46.   Attr.H = 250;
  47.   Thermometer = new TScrollBar(this, ID_THERMOMETER, 100, 150, 180, 0, TRUE);
  48.   Static = new TStatic(this, ID_STATIC, "32 degrees", 135, 40, 160, 17, 0);
  49. }
  50.  
  51. void
  52. TTestWindow::SetupWindow()
  53. {
  54.   TWindow::SetupWindow();
  55.   Thermometer->SetRange(32, 120);
  56. }
  57.  
  58. void
  59. TTestWindow::EvThermometer(uint /*code*/)
  60. {
  61.   char string[12];
  62.   sprintf(string, "%d%s", Thermometer->GetPosition(), " degrees");
  63.   Static->SetText(string);
  64. }
  65.  
  66.  
  67. //
  68. // class TTestApp
  69. // ~~~~~ ~~~~~~~~
  70. class TTestApp : public TApplication {
  71.   public:
  72.     TTestApp()
  73.     :
  74.       TApplication()
  75.     {
  76.     }
  77.  
  78.     void InitMainWindow() {
  79.       TFrameWindow* frame = new TFrameWindow(0, "Thermostat", new TTestWindow, true);
  80.       frame->EnableKBHandler();
  81.       SetMainWindow(frame);
  82.     }
  83. };
  84.  
  85. int
  86. OwlMain(int /*argc*/, char* /*argv*/ [])
  87. {
  88.   TTestApp app;
  89.   return app.Run();
  90. }
  91.